"""
    create by IAmFiveHigh on 2024/6/14
"""


class LinkListStack:
    class Node:
        def __init__(self, e):
            self.e = e
            self.next = None

    def __init__(self):
        self._dummy_node = self.Node(None)
        self._size = 0

    def get_size(self):
        return self._size

    def is_empty(self):
        return self._size == 0

    def push(self, element):
        pre = self._dummy_node
        pre = pre.next
        node = self.Node(element)
        node.next = pre
        self._dummy_node.next = node
        self._size += 1

    def pop(self):
        if self.is_empty():
            return None

        pre = self._dummy_node
        node = pre.next
        self._dummy_node.next = node.next
        node.next = None
        self._size -= 1
        return node.e


if __name__ == '__main__':
    l1 = [1, 2, 3, 4, 5]
    s1 = LinkListStack()
    for e in l1:
        s1.push(e)

    print(s1.pop())
    s1.push(10)
    print(s1.pop())
